package com.example.auth2.controller;

import com.example.auth2.service.PrivilegeUserService;
import com.example.util.model.PrivilegeUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import java.security.Principal;

//@RestController
@Controller
//@RequestMapping("/")
public class IndexController {
    private static final Logger LOG = LoggerFactory.getLogger(IndexController.class);
    @Autowired
    private PrivilegeUserService privilegeUserService;

    @GetMapping(value = "/index")
//    @ResponseBody
    public  String index(){
        return "index";
//        return "hello world !";
    }
//    @RequestMapping(value = "/login1")
    @GetMapping(value = "/login")
    public  String login(ModelMap map, Principal principal){
//        return "hello ，登录成功！";
        PrivilegeUser user = privilegeUserService.selectByPrimaryKey("admin");
        map.addAttribute("user",user);
        return "login";
    }
}
